/*
 *The code is written by NaLi, All rights reserved.
 */
package com.nali.dal.statement.function;

import java.util.List;

import com.nali.dal.statement.util.DalCollectionUtils;

/**
 * @author gavin 
 * Created on 2011-4-11
 */
public abstract class SingleArgumentDataHandler<T, V> implements DataHandler<V>{
	@Override
	public void validate(List<FunctionArgument> arguments) throws FunctionException {
		if(DalCollectionUtils.isEmpty(arguments) || arguments.size() != 1) {
			throw new FunctionException("Not valid argumetns: " + arguments);
		}
	}
	
	protected abstract V handle(T argument) throws FunctionException;

	@SuppressWarnings("unchecked")
	@Override
	public V handle(List<Object> argList) throws FunctionException {
		return this.handle((T) argList.get(0));
	}
}

